from time import sleep
from appium import webdriver
import logging
import logging.config
import sys
sys.path.append(r'..')
from common.get_yaml_data import get_yaml_data

logging.config.fileConfig(r'../config/log_conf.ini')
logger=logging.getLogger()
def desired_caps():
    data=get_yaml_data(r'../config/desired_caps.yml')
    desired_caps = {}
    desired_caps['platformName'] = data['platformName']
    desired_caps['platformVersion'] = data['platformVersion']
    desired_caps['devices'] = data['devices']
    desired_caps['app'] = data['app']
    desired_caps['appPackage'] = data['appPackage']
    desired_caps['appActivity'] = data['appActivity']
    desired_caps['noResert'] = data['noResert']
    driver = webdriver.Remote(f'http://{data["ip"]}:{data["port"]}/wd/hub', desired_caps)
    # 隐式等待
    driver.implicitly_wait(10)
    sleep(3)
    logging.info('app start success')
    return driver
if __name__ == '__main__':
    driver=desired_caps()
